<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
		<title>文章管理</title>
		[#include "/html/include/easyuicss.html" /]
		[#include "/html/include/easyuijs.html" /]
		<script type="text/javascript" src="${app }/static/js/common.utils.js"></script>
	</head>
	<body class="easyui-layout" data-options="fit:true" style="overflow-y: hidden">
	<table id="dgtable" class="easyui-datagrid" style="width:100%;height:100%;">
		<thead>
		<tr>
			<th data-options="field:'content_id',width:60">文章编号</th>
			<th data-options="field:'title',width:200">文章标题</th>
			<th data-options="field:'category_name',width:60">文章栏目</th>
			<th data-options="field:'key_words',width:100">标签</th>
			<th data-options="field:'author',width:60">文章作者</th>
			<th data-options="field:'status_name',width:60">状态</th>
			<th data-options="field:'modify_time',width:80">操作时间</th>
			<th data-options="field:'operating',width:50,formatter:getBtn">操作</th>
		</tr>
		</thead>
	</table>
	<div id="tb">
		<span>文章标题:</span>
		<input  class="easyui-textbox" id="title" name="title" style="width:200px;" />
		<span>文章栏目:</span>
		[@fl_select id="categoryId" name="categoryId" value=""
		otherAttr='style="width:120px;" class="easyui-combobox" data-options="editable:false" '
		list=Request['categorys'] headLabel="请选择..." headValue="" optionLabel="category_name" optionValue="category_id"]
		${tag_html}
		[/@fl_select]
		<span>文章状态:</span>
		[@fl_select id="status" name="status" value=""
		otherAttr='style="width:120px;" class="easyui-combobox" data-options="editable:false" '
		list=Request['status'] headLabel="请选择..." headValue="" optionLabel="item_name" optionValue="item_id"]
		${tag_html}
		[/@fl_select]
		<a href="javascript:;" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="showList();">查询</a>
		<a href="javascript:;" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="showInfo('create', '');">新增</a>
	</div>
	</body>
    <script type="text/javascript">
		$(document).ready(function(){
			$('#dgtable').datagrid({
				url: '${app}/blog/content/list.do',
				method: 'post',
				queryParams: {title: $('#title').val(),categoryId: $('#categoryId').val(),status: $('#status').val()},
				singleSelect: true,
                fitColumns: true,
				toolbar: '#tb',
				onLoadSuccess: onLoadSuccess,
				pagination: true,
				pageSize: 20,
				pageList: [10,20,30]
			});
		});
		function getBtn(value, row, index) {
			var btnStr = '<a href="javascript:;" class="easyui-linkbutton" onclick="showInfo(\'edit\', \''+row.content_id+'\');">编辑</a>&nbsp;'+
				'<a href="javascript:;" class="easyui-linkbutton" onclick="deleteInfo(\''+row.content_id+'\')">删除</a>&nbsp;';
			return btnStr;
		}
		function onLoadSuccess(data){
			$('.easyui-linkbutton').linkbutton();
		}
		function showList(){
			$('#dgtable').datagrid('load', {
                title: $('#title').val(),
				categoryId: $('#categoryId').val(),
				status: $('#status').val()
			});
		}
		function showInfo(method, id){
			parent.easyui.createWindow('文章管理',
					'${app}/blog/content/edit.do?method='+method+'&contentId='+id,
					'800px', '600px', window.name);
		}
		function deleteInfo(contentId){
			parent.easyui.confirm('系统提醒', '您确定要删除该条记录吗？', function(r){
				if (r){
					parent.layer.load(2);
					common.ajax('${app}/blog/content/delete.do', 'contentId='+contentId,
						'POST', 'json', false,
						function(result){
							parent.layer.closeAll('loading');
							parent.easyui.msgShow('系统提醒', result.msg, 3000, 250, 100);
							if (result.result == 1) {
								showList();
							}
						}
					);
				}
			});
		}
    </script>
</html>